package com.ylb.rent.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylb.rent.util.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;

import com.ruoyi.common.enums.BusinessType;
import  com.ylb.rent.entity.RoomImage;
import com.ylb.rent.service.IRoomImageService;


/**
 * 房间图片Controller
 * 
 * @author ylb
 * @date 2023-06-29
 */
@RestController
@RequestMapping("/room/image")
public class RoomImageController
{
    @Autowired
    private IRoomImageService roomImageService;

    /**
     * 查询房间图片列表
     */
    @PreAuthorize("@ss.hasPermi('room:image:list')")
    @GetMapping("/list")
    public String list(RoomImage roomImage)
    {
        ;
        List<RoomImage> list = roomImageService.selectRoomImageList(roomImage);
        return R.successJSONData(list);
    }


    /**
     * 获取房间图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('room:image:query')")
    @GetMapping(value = "/{id}")
    public String getInfo(@PathVariable("id") Long id)
    {
        return R.successJSONData(roomImageService.selectRoomImageById(id));
    }

    /**
     * 新增房间图片
     */
    @PreAuthorize("@ss.hasPermi('room:image:add')")
    @Log(title = "房间图片", businessType = BusinessType.INSERT)
    @PostMapping
    public String add(@RequestBody RoomImage roomImage)
    {
        return R.successJSONData(roomImageService.insertRoomImage(roomImage));
    }

    /**
     * 修改房间图片
     */
    @PreAuthorize("@ss.hasPermi('room:image:edit')")
    @Log(title = "房间图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public String edit(@RequestBody RoomImage roomImage)
    {
        return R.successJSONData(roomImageService.updateRoomImage(roomImage));
    }

    /**
     * 删除房间图片
     */
    @PreAuthorize("@ss.hasPermi('room:image:remove')")
    @Log(title = "房间图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public String remove(@PathVariable Long[] ids)
    {
        return R.successJSONData(roomImageService.deleteRoomImageByIds(ids));
    }
}
